/*
 * Copyright (c) 2023 Kamillaova. All rights reserved.
 *
 * This software is licensed under the WebK8S End-User License Agreement (EULA).
 * A copy of the EULA is included in the repository's LICENSE file.
 *
 * For non-commercial usage only. Modifications must be published under the same license.
 */

//go:build linux

package fs

import (
	"github.com/funcid/web-k8s/pkg/sysinfo/internal/types"
	"golang.org/x/sys/unix"
)

func FS(path string) (types.FS, error) {
	var statfs unix.Statfs_t

	if err := unix.Statfs(path, &statfs); err != nil {
		return types.FS{}, err
	}

	return types.FS{
		BytesAvailable: statfs.Bavail * uint64(statfs.Bsize),
	}, nil
}
